/**
 * 通用的组件工具方法
 * @author wennn
 * @time   2019-12-17
 */

/**
  * 判断是否为空
  * @param {*} a
  */
export function isNull(a){
	return a == null;
}

/**
 * 合并classname
 * @param {*} aClass
 * @param {*} bClass
 */
export function mergeClassName(aClass,bClass){
	return (isNull(aClass)?'':aClass)+' '+(isNull(bClass)?'':bClass);
}

const childToArray = children => Array.isArray(children)?children:[children];

/**
 * 元素遍历
 * @param {元素} children 
 * @param {回调函数} cb 
 */

export function mapChild(children,cb){
	return childToArray(children).map(cb);
}

export function forEachChild(children,cb){
	childToArray(children).forEach(cb);
}

